import http from "@/utils/http";
import { AxiosRequestConfig } from "axios";

export interface PutAuthorizeById_ {
  /**
   * @description 看板的id
   */
  id: number;
}
export interface PutCollectById_ {
  /**
   * @description 看板的id
   */
  id: number;
}
export interface DeleteCollectById_ {
  /**
   * @description 看板的id
   */
  id: number;
}
export interface GetPageable_ {
  /**
   * @description 看板目录的id
   * @format int32
   */
  dirId?: number;
  /**
   * @description 是否收藏，不传默认同时展示收藏和未收藏的
   */
  isFavorite?: boolean;
  /**
   * @description 是否发布，不传默认同时展示发布和未发布的
   */
  isPublished?: boolean;
  /**
   * @description 看板标签的id列表
   */
  labelIds?: number[];
  /**
   * @description 看板名称
   */
  name?: string;
  /**
   * @description 页数
   * @format int32
   * @min 1
   */
  pageNum?: number;
  /**
   * @description 条数
   * @format int32
   * @min 1
   */
  pageSize?: number;
  /**
   * @description 看板浏览的类型。1：公共看板，2：我创建的看板，3：获得授权的看板
   * @format int32
   */
  reviewType?: 1 | 2 | 3;
  /**
   * @description 看板类型。1：指标，2：指标树
   * @format int32
   */
  type?: number;
}
export interface PutPublishById_ {
  /**
   * @description 看板的id
   */
  id: number;
}
export interface DeletePublishById_ {
  /**
   * @description 看板的id
   */
  id: number;
}
export interface DeleteById_ {
  /**
   * @description 看板的id
   */
  id: number;
}

export class Board {
  /**
   * 授权看板
   *
   * @tags 看板模块
   * @request PUT: /board/authorize/{id}
   * @secure
   */
  putAuthorizeById = (
    { id }: { id: number } | PutAuthorizeById_,
    authorizeBoardDto: defs.AuthorizeBoardDto,
    params: AxiosRequestConfig = {},
  ) =>
    http.request<defs.ResponseEntityString>({
      url: `/board/authorize/${id}`,
      method: "PUT",
      data: authorizeBoardDto,
      ...params,
    });

  /**
   * 收藏看板
   *
   * @tags 看板模块
   * @request PUT: /board/collect/{id}
   * @secure
   */
  putCollectById = ({ id }: { id: number } | PutCollectById_, params: AxiosRequestConfig = {}) =>
    http.request<defs.ResponseEntityString>({
      url: `/board/collect/${id}`,
      method: "PUT",
      ...params,
    });

  /**
   * 取消收藏看板
   *
   * @tags 看板模块
   * @request DELETE: /board/collect/{id}
   * @secure
   */
  deleteCollectById = ({ id }: { id: number } | DeleteCollectById_, params: AxiosRequestConfig = {}) =>
    http.request<defs.ResponseEntityString>({
      url: `/board/collect/${id}`,
      method: "DELETE",
      ...params,
    });

  /**
   * 搜索看板，提供(可分页地)按名称、类型、标签查询看板的功能
   *
   * @tags 看板模块
   * @request GET: /board/pageable
   * @secure
   */
  getPageable = (
    query:
      | {
          dirId?: number;
          isFavorite?: boolean;
          isPublished?: boolean;
          labelIds?: number[];
          name?: string;
          pageNum?: number;
          pageSize?: number;
          reviewType?: 1 | 2 | 3;
          type?: number;
        }
      | GetPageable_,
    params: AxiosRequestConfig = {},
  ) =>
    http.request<defs.ResponseEntityPageInfoBoardVO>({
      url: `/board/pageable`,
      method: "GET",
      params: query,
      ...params,
    });

  /**
   * 发布看板
   *
   * @tags 看板模块
   * @request PUT: /board/publish/{id}
   * @secure
   */
  putPublishById = (
    { id }: { id: number } | PutPublishById_,
    publishBoardDto: defs.PublishBoardDto,
    params: AxiosRequestConfig = {},
  ) =>
    http.request<defs.ResponseEntityString>({
      url: `/board/publish/${id}`,
      method: "PUT",
      data: publishBoardDto,
      ...params,
    });

  /**
   * 下线看板
   *
   * @tags 看板模块
   * @request DELETE: /board/publish/{id}
   * @secure
   */
  deletePublishById = ({ id }: { id: number } | DeletePublishById_, params: AxiosRequestConfig = {}) =>
    http.request<defs.ResponseEntityString>({
      url: `/board/publish/${id}`,
      method: "DELETE",
      ...params,
    });

  /**
   * 删除看板
   *
   * @tags 看板模块
   * @request DELETE: /board/{id}
   * @secure
   */
  deleteById = ({ id }: { id: number } | DeleteById_, params: AxiosRequestConfig = {}) =>
    http.request<defs.ResponseEntityString>({
      url: `/board/${id}`,
      method: "DELETE",
      ...params,
    });
}

export default new Board();
